home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- '''Class for parsing ASN.1'''
- from compat import *
- from codec import *
-
- class ASN1Parser:
-
- def __init__(self, bytes):
- p = Parser(bytes)
- p.get(1)
- self.length = self._getASN1Length(p)
- self.value = p.getFixBytes(self.length)
-
-
- def getChild(self, which):
- p = Parser(self.value)
- for x in range(which + 1):
- markIndex = p.index
- p.get(1)
- length = self._getASN1Length(p)
- p.getFixBytes(length)
-
- return ASN1Parser(p.bytes[markIndex:p.index])
-
-
- def _getASN1Length(self, p):
- firstLength = p.get(1)
- if firstLength <= 127:
- return firstLength
- lengthLength = firstLength & 127
- return p.get(lengthLength)
-
-
-